﻿namespace PayPal.ButtonManager
{
    using System.Collections.Generic;
    using System.ComponentModel;

    public class HtmlButtonVariablesHelper
    {
        public static Dictionary<string, string> GetProperties(dynamic buttonProperties)
        {
            Dictionary<string, string> properties = new Dictionary<string, string>();

            if (buttonProperties != null)
            {
                PropertyDescriptorCollection props = TypeDescriptor.GetProperties(buttonProperties);
                foreach (PropertyDescriptor prop in props)
                {
                    object val = prop.GetValue(buttonProperties);
                    if (val != null)
                    {
                        properties.Add(HtmlButtonVariables.GetVariableName(prop.Name), val.ToString());
                    }
                }
            }

            return properties;
        }
    }
}
